//
//  BLPartyMomentController.m
//  Byelone
//
//  Created by Qi Liu on 2021/2/23.
//

#import "BLPartyMomentController.h"
#import "BLMomentModel.h"
#import "BL_MomentCell.h"
#import "BLCommentCell.h"
#define MomentCell @"BL_MomentCell"
#define CommentCell @"BLCommentCell"

typedef NS_ENUM(NSUInteger, ReplyType) {
    ReplyType_Moment = 1, //评论
    ReplyType_Comment
};

@interface BLPartyMomentController ()<UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate,ChatKeyBoardDelegate, ChatKeyBoardDataSource>
@property (nonatomic, strong) WMPageController *pageController;
//分页页数 && 分页序号
@property(nonatomic,assign)NSInteger  pageNo;
@property(nonatomic,assign)NSInteger  pageSize;
@property(nonatomic,copy)NSDictionary *  pramas;
@property(nonatomic,copy)NSMutableArray * listArray;
@property (nonatomic,copy) NSDictionary * urlDic;
@property(nonatomic,strong)UITableView * listTableview;
@property(nonatomic,assign) MomentVCType vcType;
@property (nonatomic, strong) ChatKeyBoard *chatKeyBoard;

@property(nonatomic,assign) BOOL isPlay;
@property(nonatomic,strong) BL_MomentCell * reloadCell;
@property (nonatomic,strong) BLMomentModel * momentModel;
@property (nonatomic,strong) ReplyModel * replyModel;
@property (nonatomic,assign) NSIndexPath * handelIndex;
@property (nonatomic,assign) ReplyType replyType;


@property (nonatomic, strong) ZFPlayerController *player;
@property (nonatomic, strong) ZFPlayerControlView *controlView;
@end

@implementation BLPartyMomentController

+(instancetype)createMomentVCWithType:(MomentVCType)type{
    BLPartyMomentController * momnet = [[BLPartyMomentController alloc]init];
    momnet.vcType = type;
    return momnet;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    _pageNo = 1;
    _pageSize = 10;
    _listArray = [NSMutableArray array];
    
    [self setUpUrl];
    [self keyBoardHandel];//键盘处理
    [self zfPlayer];//播放器处理
    [self loadData];//数据请求
}

-(NSDictionary *)pramas{
    return @{@"pageNo":BL_WTAPSTRING(_pageNo),
             @"pageSize":BL_WTAPSTRING(_pageSize)
    };
}

-(void)loadData{
    
    [BLHttpTool postWithPath:[_urlDic objectForKey:@(_vcType)] params:self.pramas successBlock:^(NSDictionary * _Nonnull obj) {
        NSArray * array = [BLMomentModel mj_objectArrayWithKeyValuesArray:[[obj objectForKey:@"content"] objectForKey:@"list"]];
        [self.listArray removeAllObjects];
        [self.listArray addObjectsFromArray:array];
        NSLog(@"%@",array);
        [self.listTableview reloadData];
        [self->_listTableview.mj_header endRefreshing];
    } failedBlock:^(NSURLSessionDataTask * _Nonnull data, NSError * _Nonnull error) {
        [self->_listTableview.mj_header endRefreshing];
    }];
}

-(UITableView *)listTableview{
    if (!_listTableview) {
        _listTableview=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, BL_WINDOW_WIDTH, BL_TABCONTENT_HEIGHT ) style:UITableViewStylePlain];
        _listTableview.backgroundColor=[UIColor chColorWithHexString:@"#FAFAFB"];
        _listTableview.showsVerticalScrollIndicator = NO;
        _listTableview.dataSource = self;
        _listTableview.delegate = self;
        _listTableview.separatorStyle = UITableViewCellSeparatorStyleNone;
        _listTableview.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadData)];
        _listTableview.tableFooterView = [[UIView alloc] init];
        [_listTableview registerNib:[UINib nibWithNibName:MomentCell bundle:nil] forCellReuseIdentifier:MomentCell];
        [_listTableview registerNib:[UINib nibWithNibName:CommentCell bundle:nil] forCellReuseIdentifier:CommentCell];
        [self.view addSubview:_listTableview];
    }
    return _listTableview;
}

//MARK:delegate && datasoure
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.listArray.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    BLMomentModel * model = [self.listArray objectAtIndex:section];
    return model.replyList.count + 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return UITableViewAutomaticDimension;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    BOOL hideBtn = (_vcType != MomentVCType_Self);
    
    BLMomentModel * model = [self.listArray objectAtIndex:indexPath.section];
    if (indexPath.row == 0) {
        
        BL_MomentCell * cell = [[[NSBundle mainBundle] loadNibNamed:MomentCell owner:nil options:nil]lastObject];
        if (_isPlay && indexPath.section == _handelIndex.section && indexPath.row == _handelIndex.row) {
            cell = _reloadCell;
            _reloadCell = nil;
            _isPlay = NO;
            return cell;
        }
        cell.commentModel = model;
        cell.curIndex = indexPath;
        cell.deleteBtn.hidden = hideBtn;
        
        //喜欢
        cell.likeBlock = ^(BLMomentModel * _Nonnull model, NSIndexPath * _Nonnull curIndex ,UIButton * likeBtn) {
            [self handelLike:curIndex momentModel:model btn:likeBtn];
        };
        //评论
        cell.commentBlock = ^(BLMomentModel * _Nonnull model, NSIndexPath * _Nonnull curIndex) {
            [self handelRepyMoment:curIndex momentModel:model replyType:ReplyType_Moment];
        };
        //播放视频
        cell.playBlock = ^(BLMomentModel * _Nonnull model, NSIndexPath * _Nonnull curIndex) {
            [self playVideo:curIndex momentModel:model];
        };
        //删除动态
        cell.deleteBlock = ^(BLMomentModel * _Nonnull model, NSIndexPath * _Nonnull curIndex) {
            [self deleteMomentWith:curIndex momentModel:model];
        };
        return cell;
        
    }else{
        
        BLCommentCell * cell = [tableView dequeueReusableCellWithIdentifier:CommentCell];
        if (cell == nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"BLCommentCell" owner:nil options:nil]lastObject];
        }
        cell.replayModel = [model.replyList objectAtIndex:indexPath.row - 1];
        cell.deletBtn.hidden = hideBtn;
        cell.curIndex = indexPath;
        cell.replyBlock = ^(ReplyModel * _Nonnull repModel) {
            
        };
        
        cell.deleteBlock = ^(ReplyModel * _Nonnull repModel, NSIndexPath * _Nonnull curIndex) {
            [self deleteCommentWith:curIndex momentModel:repModel];
        };
        
        return cell;
    }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"section:%ld - row:%ld",(long)indexPath.section,indexPath.row);
    if (indexPath.row != 0) {
        BLMomentModel * momentModel = [self.listArray objectAtIndex:indexPath.section];
        ReplyModel * replyModel = [momentModel.replyList objectAtIndex:indexPath.row - 1];
        
        if ([replyModel.replyUser.userId isEqualToString:[BLUserManager shareUser].baseInfo.userId]) {
            //用户自己的评论
            
            UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"删除我的评论" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
            
            UIAlertAction *alertT = [UIAlertAction actionWithTitle:@"删除" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [self deleteCommentWith:indexPath momentModel:replyModel];
            }];
            
            UIAlertAction *alertF = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                
                NSLog(@"点击了取消");
                
            }];
            
            [actionSheet addAction:alertT];
            
            [actionSheet addAction:alertF];
            
            [self presentViewController:actionSheet animated:YES completion:nil];
            
            
        }else{
            _replyModel = replyModel;
            if (_vcType != MomentVCType_Self) {
                return;
            }
            [self handelRepyMoment:indexPath momentModel:momentModel replyType:ReplyType_Comment];
        }
    }
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *viewBj = [[UIView alloc]initWithFrame:CGRectMake(0, 0, BL_WINDOW_WIDTH, 10)];
    viewBj.backgroundColor = [UIColor clearColor];
    viewBj.layer.masksToBounds = YES;
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(15, -10, BL_WINDOW_WIDTH-30, 20)];
    view.backgroundColor = [UIColor whiteColor];
    view.layer.cornerRadius = 10;
    [view setShadowRadius:6 color:BL_COLOR_PURPLE_L(0.12) offset:CGSizeMake(0, 0) opacity:1];
    [viewBj addSubview:view];
    return viewBj;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 12;
}

-(void)handelLike:(NSIndexPath *)index momentModel:(BLMomentModel *)model btn:(UIButton *)btn{
    //1 点赞 2取消
    NSInteger like = [model.like integerValue] == 0 ? 1:2;
    NSDictionary * likeDic = @{@"momentId":@([model.momentId integerValue]),
                               @"likeType":@(like)
    };
    
    [BLHttpTool postWithPath:BL_MOMENT_LIKE params:likeDic successBlock:^(NSDictionary * _Nonnull obj) {
        BLMomentModel * momnetModel = [self.listArray objectAtIndex:index.section];
        BOOL likeState = like == 1? YES : NO;
        NSInteger likeNumAdd = likeState ? 1: -1;
        
        momnetModel.like = [NSString stringWithFormat:@"%d",likeState];
        momnetModel.likeNum = [NSString stringWithFormat:@"%ld",[momnetModel.likeNum integerValue] + likeNumAdd];
        [btn setTitle:momnetModel.likeNum forState:UIControlStateNormal];
        if (likeState) {
            [btn setImage:[UIImage imageNamed:@"praise"] forState:UIControlStateNormal];
        }else{
            [btn setImage:[UIImage imageNamed:@"no_praise"] forState:UIControlStateNormal];
        }
    } failedBlock:^(NSURLSessionDataTask * _Nonnull data, NSError * _Nonnull error) {
        
    }];
}

//删除动态
-(void)deleteMomentWith:(NSIndexPath *)index momentModel:(BLMomentModel *)model{
    
    NSInteger momentId = [model.momentId integerValue];
    [BLHttpTool postWithPath:BL_MOMENT_DELETE params:@{@"momentId":@(momentId)} successBlock:^(NSDictionary * _Nonnull obj) {
        [HUD showtip:@"动态删除成功"];
        if (index.section < [self.listArray count]) {
            [self.listArray removeObjectAtIndex:index.section];
            [self.listTableview deleteSections:[NSIndexSet indexSetWithIndex:index.section] withRowAnimation:UITableViewRowAnimationNone];
        }
    } failedBlock:^(NSURLSessionDataTask * _Nonnull data, NSError * _Nonnull error) {
        [HUD showtip:@"动态删除失败"];
    }];
}
//评论
-(void)handelRepyMoment:(NSIndexPath *)index momentModel:(BLMomentModel *)model replyType:(ReplyType)replytype{
    _handelIndex = index;
    _momentModel = model;
    _replyType = replytype;
    _isPlay = YES;
    NSIndexPath * indexComment = index;
    if (_replyType == ReplyType_Comment) {
        indexComment = [NSIndexPath indexPathForRow:0 inSection:index.section];
    }
    _reloadCell = [self.listTableview cellForRowAtIndexPath:index];
    
    
    
    //    }
    
    
    //    [self.listTableview setContentOffset:CGPointMake(0.0, 200) animated:NO];
    //    [self.listTableview scrollToRowAtIndexPath:index atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
    
    //    CGRect rectInTableView = [_listTableview rectForRowAtIndexPath:index];//获取cell在tableView中的位置
    //    CGRect rectInSuperview = [_listTableview convertRect:rectInTableView toView:[_listTableview superview]];
    //    if (self.listTableview.height - CGRectGetMaxY(cellFrame) < 50){
    //        CGFloat offset = (self.listTableview.height + 49)  - CGRectGetMaxY(cellFrame);
    //        NSLog(@"需要便宜的值:%f",offset);
    //    }
    //    NSLog(@"此时的cell 起始位置位置y:%f，y最大值:%f,最大偏移量：%f",rectInSuperview.origin.y,rectInSuperview.size.height,CGRectGetMaxY(rectInSuperview));
    
    //   [self.listTableview reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, _momentModel.momentUrlList.count)] withRowAnimation:UITableViewRowAnimationNone];
    //
    //    [self.listTableview reloadRowsAtIndexPaths:[NSIndexPath indexPathWithIndexes:@[]] withRowAnimation:UITableViewRowAnimationNone];
    
    
    [self.chatKeyBoard keyboardUpforComment];
}


-(void)handelMessage:(NSString * )contentStr{
    if (contentStr.length <= 0) {
        [HUD showtip:@"内容不能为空"];
        return;
    }
    
    NSMutableDictionary * replyDic = [NSMutableDictionary dictionaryWithDictionary:@{@"replyType":@(_replyType),
                                                                                     @"momentId":_momentModel.momentId,
                                                                                     @"replyContent":contentStr,
    }];
    
    if (_replyType == ReplyType_Comment) {
        if (_replyModel) {
            NSString * replyId =  [NSString stringWithFormat:@"%@",_replyModel.replyId];
            [replyDic setValue:replyId forKey:@"replyId"];
        }
    }
    [BLHttpTool postWithPath:BL_MOMENT_REPLY params:replyDic successBlock:^(NSDictionary * _Nonnull obj) {
        NSArray * replyArray = [ReplyModel mj_objectArrayWithKeyValuesArray:[[obj objectForKey:@"content"] objectForKey:@"replyList"]];
        BLMomentModel * momentModel = [self.listArray objectAtIndex:self.handelIndex.section];
        momentModel.replyList = replyArray;
        [UIView setAnimationsEnabled:NO];
        [self.listTableview reloadSections:[NSIndexSet indexSetWithIndex:self.handelIndex.section] withRowAnimation:UITableViewRowAnimationNone];
        [UIView setAnimationsEnabled:YES];
        
    } failedBlock:^(NSURLSessionDataTask * _Nonnull data, NSError * _Nonnull error) {
        
    }];
    
}

//删除评论
-(void)deleteCommentWith:(NSIndexPath *)index momentModel:(ReplyModel *)model{
    
    _handelIndex = index;


    NSIndexPath *   indexComment = [NSIndexPath indexPathForRow:0 inSection:index.section];
 
    _reloadCell = [self.listTableview cellForRowAtIndexPath:indexComment];
    
    
    NSDictionary * params = @{@"replyId":model.replyId};
    [BLHttpTool postWithPath:BL_MOMENT_DELETE_REPLY params:params successBlock:^(NSDictionary * _Nonnull obj) {
      
        BLMomentModel * momentModel = [self.listArray objectAtIndex:index.section];
       
        NSMutableArray * array =  [NSMutableArray arrayWithArray:momentModel.replyList];
        
        __block NSMutableArray * deleteArray = [NSMutableArray array];
        
        [array enumerateObjectsUsingBlock:^(ReplyModel  * obj, NSUInteger idx, BOOL * _Nonnull stop) {
            if ([obj.replyId isEqualToString:model.replyId]) {
                [deleteArray addObject:obj];
            }
        }];
        
        [array removeObjectsInArray:deleteArray];
        
        momentModel.replyList = array;
        
        [UIView setAnimationsEnabled:NO];
        [self.listTableview reloadSections:[NSIndexSet indexSetWithIndex:index.section] withRowAnimation:UITableViewRowAnimationNone];
        [UIView setAnimationsEnabled:YES];
        
    } failedBlock:^(NSURLSessionDataTask * _Nonnull data, NSError * _Nonnull error) {
        
    }];
}

-(void)playVideo:(NSIndexPath *)index momentModel:(BLMomentModel *)model{
    
    _handelIndex = index;
    
    URLModel * urlModel = [model.momentUrlList firstObject];
    [self.player playTheIndexPath:index assetURL:[NSURL URLWithString:urlModel.momentUrl]];
    [self.controlView showTitle:@""
                 coverURLString:@""
                 fullScreenMode:urlModel.isVerticalContent?ZFFullScreenModePortrait:ZFFullScreenModeLandscape];
    
}


-(void)testRloadCell{
    
    NSLog(@"开始刷新section");
    [self.listTableview reloadSections:[NSIndexSet indexSetWithIndex:_handelIndex.section] withRowAnimation:UITableViewRowAnimationNone];
    
}


#pragma mark - UIScrollViewDelegate 列表播放必须实现

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    [scrollView zf_scrollViewDidEndDecelerating];
}

- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView {
    [scrollView zf_scrollViewDidScrollToTop];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    [scrollView zf_scrollViewDidScroll];
}
//gif 播放控制
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
    [scrollView zf_scrollViewWillBeginDragging];
    //收起键盘
    [self.chatKeyBoard keyboardDownForComment];
    
    NSArray* cells = _listTableview.visibleCells;
    [cells enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if ([obj isKindOfClass:[BL_MomentCell class]]) {
            BL_MomentCell * cell = (BL_MomentCell *)obj;
            [cell stopAnimationGif];
        }
    }];
}
//停止拖拽
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    [scrollView zf_scrollViewDidEndDraggingWillDecelerate:decelerate];
    NSArray* cells = _listTableview.visibleCells;
    [cells enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if ([obj isKindOfClass:[BL_MomentCell class]]) {
            BL_MomentCell * cell = (BL_MomentCell *)obj;
            [cell startAnimationGif];
        }
    }];
    
    //    NSArray * indexs = [_listTableview indexPathsForVisibleRows];
    //    [indexs enumerateObjectsUsingBlock:^(NSIndexPath * obj, NSUInteger idx, BOOL * _Nonnull stop) {
    //        CGRect cellR = [_listTableview rectForRowAtIndexPath:obj];
    //        UITableViewCell * cell = [_listTableview cellForRowAtIndexPath:obj];
    //        if ([cell isKindOfClass:[BL_MomentCell class]]) {
    //
    //            BL_MomentCell * momnetCell = (BL_MomentCell *)cell;
    //            if (_listTableview.contentOffset.y - cellR.origin.y < momnetCell.frame.size.height || //在 最下面消失
    //                cellR.origin.y - _listTableview.contentOffset.y >_listTableview.size.height) { //还未出现在课时区域
    //                //这个时候myCell应该是不在myTV的可视区域了。
    //                [momnetCell stopAnimationGif];
    //                NSLog(@"停止播放gif");
    //            } else {//myCell在可视区域时，业务处理
    //                [momnetCell startAnimationGif];
    //                NSLog(@"开始播放gif");
    //            }
    //        }
    //
    //    }];
    
    
}


////cell将要出现（显示出来）的时候调用，紧跟着cellForRowAtIndexPath调用
//- (void)tableView:(UITableView*)tableView willDisreloadCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath {
//
//    NSLog(@"willDisreloadCell---%ld",(long)indexPath.row);
//
//    if(indexPath.row==1|| indexPath.row==2) {
//        cell.textLabel.textColor = [UIColor redColor];
//    }
//}
////cell完全消失（不见）的时候调用
////这个在自适应高度的cell里好像不太准确 这个以后再说
- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([tableView.indexPathsForVisibleRows indexOfObject:indexPath] == NSNotFound)
    {
        BL_MomentCell * cell = [tableView cellForRowAtIndexPath:indexPath];
        [cell stopAnimationGif];
        NSLog(@"停止播放gif");
    }
}

//MARK:键盘操作

-(void)keyBoardHandel{
    self.chatKeyBoard = [ChatKeyBoard keyBoard];
    self.chatKeyBoard.delegate = self;
    self.chatKeyBoard.dataSource = self;
    self.chatKeyBoard.keyBoardStyle = KeyBoardStyleComment;
    self.chatKeyBoard.placeHolder = @"回复星星";
            self.chatKeyBoard.associateTableView = self.listTableview;
    self.chatKeyBoard.allowVoice = NO;
    self.chatKeyBoard.allowMore = NO;
    self.chatKeyBoard.allowSwitchBar = NO;
    self.chatKeyBoard.allowSendBtn = YES;
    [BL_WINDOW addSubview:self.chatKeyBoard];
    
}

- (void)chatKeyBoardSendText:(NSString *)text
{
    NSLog(@"输入的文字:%@",text);
    [self handelMessage:text];
    //发送文本
}

- (NSArray<FaceThemeModel *> *)chatKeyBoardFacePanelSubjectItems
{
    NSMutableArray *subjectArray = [NSMutableArray array];
    NSArray *sources = @[@"face"];
    for (int i = 0; i < sources.count; ++i)
    {
        NSString *plistName = sources[i];
        NSString *plistPath = [[NSBundle mainBundle] pathForResource:plistName ofType:@"plist"];
        NSDictionary *faceDic = [NSDictionary dictionaryWithContentsOfFile:plistPath];
        NSArray *allkeys = faceDic.allKeys;
        
        FaceThemeModel *themeM = [[FaceThemeModel alloc] init];
        themeM.themeStyle = FaceThemeStyleCustomEmoji;
        themeM.themeDecribe = [NSString stringWithFormat:@"f%d", i];
        NSMutableArray *modelsArr = [NSMutableArray array];
        
        for (int i = 0; i < allkeys.count; ++i) {
            NSString *name = allkeys[i];
            FaceModel *fm = [[FaceModel alloc] init];
            fm.faceTitle = name;
            fm.faceIcon = [faceDic objectForKey:name];
            [modelsArr addObject:fm];
        }
        themeM.faceModels = modelsArr;
        
        [subjectArray addObject:themeM];
    }
    
    return subjectArray;
}
- (NSArray<ChatToolBarItem *> *)chatKeyBoardToolbarItems
{
    ChatToolBarItem *item1 = [ChatToolBarItem barItemWithKind:kBarItemFace normal:@"face" high:@"face" select:@"keyboard" title:@""];
    ChatToolBarItem *item3 = [ChatToolBarItem barItemWithKind:kBarItemSend normal:@"more_ios" high:@"more_ios_HL" select:nil title:@"发送"];
    return @[item1, item3];
}


//MARK:视频播放处理
-(void)zfPlayer{
    /// playerManager
    ZFAVPlayerManager *playerManager = [[ZFAVPlayerManager alloc] init];
    /// player的tag值必须在cell里设置
    self.player = [ZFPlayerController playerWithScrollView:self.listTableview playerManager:playerManager containerViewTag:kPlayerViewTag];
    self.player.controlView = self.controlView;
    self.player.shouldAutoPlay = NO;
    /// 1.0是完全消失的时候
    self.player.playerDisapperaPercent = 1.0;
    
    @zf_weakify(self)
    self.player.orientationWillChange = ^(ZFPlayerController * _Nonnull player, BOOL isFullScreen) {
        BLPPDelegate.allowOrentitaionRotation = isFullScreen;
    };
    
    self.player.playerDidToEnd = ^(id  _Nonnull asset) {
        @zf_strongify(self)
        [self.player stopCurrentPlayingCell];
    };
}
- (ZFPlayerControlView *)controlView {
    if (!_controlView) {
        _controlView = [ZFPlayerControlView new];
        _controlView.prepareShowLoading = YES;
        _controlView.prepareShowControlView = YES;
    }
    return _controlView;
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.player.viewControllerDisappear = NO;
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.player.viewControllerDisappear = YES;
}


- (BOOL)prefersStatusBarHidden {
    return NO;
}

-(void)setUpUrl{
    _urlDic = @{@(0):BL_MOMENT_LIFE_LIST,
                @(1):BL_MOMENT_LIKT_LIST,
                @(2):BL_MOMENT_SELF_LIST
    };
}

@end
